import java.io.*;
import java.util.StringTokenizer;

public class 小红接雨水 {

    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    public static int a,b,c;
    public static void main(String[] args) throws IOException {
        a = in.nextInt();
        b = in.nextInt();
        c = in.nextInt();
        // 中间高两边低一定不行
        if (b >= a || b >= c) {
            out.print(0);
        } else {
            // 两边高取小的木桶效应
            out.print(Math.min(a,c) - b);
        }
        out.close();
    }






    public static class Read { // 自定义快速读入
        StringTokenizer st = new StringTokenizer("");
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

        String next() throws IOException {
            while (!st.hasMoreTokens()) {
                st = new StringTokenizer(bf.readLine());
            }
            return st.nextToken();
        }

        String nextLine() throws IOException {
            return bf.readLine();
        }

        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }
    }
}
